package service

import (
	"context"
	"sgw-services/api/rate/service/v1"
	"sgw-services/app/rate/service/internal/biz"

	"github.com/go-kratos/kratos/v2/log"
)

// RateService is a greeter service.
type RateService struct {
	v1.UnimplementedRateServer

	uc  *biz.RateUsecase
	log *log.Helper
}

// NewRateService new a greeter service.
func NewRateService(uc *biz.RateUsecase, logger log.Logger) *RateService {
	return &RateService{uc: uc, log: log.NewHelper(logger)}
}

// SayHello implements rate.service.v1.RateServer
func (s *RateService) Quote(ctx context.Context, in *v1.HelloRequest) (*v1.HelloReply, error) {
	s.log.WithContext(ctx).Infof("SayHello Received: %v", in.GetName())

	if in.GetName() == "error" {
		return nil, v1.ErrorUserNotFound("user not found: %s", in.GetName())
	}
	return &v1.HelloReply{Message: "Hello " + in.GetName()}, nil
}
